//tab选项卡--右下
let tbList=document.querySelectorAll(".dt .tb")
let spanList=document.querySelectorAll(".fir span")
function hide(index){
	for(var i=0;i<spanList.length;i++){
		spanList[i].id="";
		tbList[i].id="";
	}
	spanList[index].id="focus"
	tbList[index].id="show";
}
for(var i=0;i<spanList.length;i++){
	spanList[i].setAttribute("sp-list",i);
	spanList[i].onclick=function(){
		index=Number(this.getAttribute("sp-list"))
		hide(index)
	}
}
//左侧导航栏
let liList=$("#box li")
let dpTabList=$("#box li .dp-tab")
function hid(n){
	for(let i=0;i<liList.length;i++){
		liList[i].id=""
		dpTabList[i].id=""
	}
	liList[n].id="in"
	dpTabList[n].id="on"
}
for(let k=0;k<liList.length;k++){
	liList[k].setAttribute("air",k)
	liList[k].onclick=function(){
		n=Number(this.getAttribute("air"))
		hid(n)
		console.log(n)
	}
	liList[k].onmouseenter=function(){
		$(".hide").css({"display":"block"})
	}
	liList[k].onmouseleave=function(){
		$(".hide").css({"display":"none"})
	}
}
//错号
let em=document.querySelector(".down em")
em.onclick=function(){
	this.parentNode.remove()
}
let timer =setTimeout(()=>{
	$(".down").remove()
	clearTimeout(timer)
},2000)
//cookie-------------
let name=document.cookie;
$(".sp2")[0].innerHTML=name.split("=")[1]
//商品列表--------------
function getTypeId() {
	return location.search.split("=")[1];//也就是typeId=001,拿到的是001,002
}
function getGoodsInfo() {
		$.get("php/getGoodsList.php", { "typeId": getTypeId() }, function (data) {
			let htmlStr = "";
			data.forEach(goods => {
				console.log(goods.goodsType)
				htmlStr += `
					<a href='weidian_dianpu.html'>
						<div class="bl"><img src="${goods.goodsImg}"></div>
						<div class="br">
							<p class="typeId">商品类型:${goods.goodsType}</p>
							<p class="goodsId">商品编号:${goods.goodsId}</p>
							<p class="goodsName">商品名称:${goods.goodsName}</p>
							<p class="goodsPrice">商品单价:￥${goods.goodsPrice}</p>
							<p class="goodsCount">商品数量:${goods.goodsCount}</p>
							<p class="goodsDesc">商品描述:${goods.goodsDesc}</p>
							<p class="beiyong2">颜色:${goods.beiyong2}</p>
						</div>	
					</a>	
				`;
			});
			$(".con04>.b").html(htmlStr);    
		},"json")
}
$(function () {
	//获取商品信息
	getGoodsInfo()
})
//